package com.mars.rabbitmq.delay;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author King
 * @create 2020/8/19 10:32
 */
@Data
@Slf4j
@Configuration
public class OrderRabbitMqConfig {

    public static final String EXCHANGE = "marsOrderExchange";
    public static final String QUEUE = "marsOrderQueue";
    public static final String ROUTING_KEY = "marsOrderRoutingKey";


    @Bean
    public DirectExchange kingOrderExchange() {
        return new DirectExchange(EXCHANGE);
    }

    @Bean
    public Queue kingOrderQueue() {
        return new Queue(QUEUE);
    }

    @Bean
    public Binding kingOrderBinding() {
        return BindingBuilder.bind(kingOrderQueue()).to(kingOrderExchange()).with(ROUTING_KEY);
    }

}
